import java.util.Scanner;

//最小花费爬楼梯
public class test2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();//数组长度
        int[] costs = new int[len];//支付数组
        for (int i = 0; i <len ; i++) {
            costs[i] = scanner.nextInt();
        }

        //对楼层进行判断.当前为第 i 层,对到 i-1 和 i-2 的费用进行比较,选小的
        //第0和第1不需要花费
        int cost = choice(costs);
        System.out.println(cost);
    }
    public static int choice(int[] costs){
        int[] cost2 = new int[costs.length+1];
        for (int i = 2; i < costs.length+1; i++) {//计算第0 1
            cost2[i] = min(cost2[i-1]+costs[i-1],cost2[i-2]+costs[i-2]);
        }
        return cost2[costs.length];
    }

    public static int min(int a,int b){
        if(a>=b){
            return b;
        }else {
            return a;
        }
    }
}
